package com.hisense.proxy.busitrans.controller;

import com.alibaba.fastjson.JSON;
import com.hisense.proxy.busitrans.vo.QrcodeReqVO;
import com.hisense.proxy.service.utils.QrcodeUtil;
import lombok.extern.slf4j.Slf4j;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Base64;

/**
 * <p>
 *
 * </p>
 *
 * @author tangxqa
 * @since 2021/9/3 12:32 下午
 */
@RestController
@RequestMapping("qrcode")
public class HxFdcprQrcodeReqController {
    private static Logger log = LoggerFactory.getLogger(HxFdcprQrcodeReqController.class);

    @PostMapping("/")
    public String getQrcode(@RequestBody QrcodeReqVO qrcodeReqVO) throws Exception {
    	log.info("Request qrcode params: {}", JSON.toJSON(qrcodeReqVO));
        byte[] bytes = new QrcodeUtil().createQRCode(qrcodeReqVO.getContent(), qrcodeReqVO.getWidth(), qrcodeReqVO.getHeight());
        return Base64.getEncoder().encodeToString(bytes);
    }


}



